forked from git-for-windows/git
    
        
        - 
                Notifications
    You must be signed in to change notification settings 
- Fork 106
          Fix sparse-checkout set crashes
          #607
        
          New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
            vdye
  merged 3 commits into
  microsoft:vfs-2.42.0
from
vdye:vdye/sparse-checkout-crash-fix
  
      
      
   
  Sep 20, 2023 
      
    
                
     Merged
            
            
  
    Fix sparse-checkout set crashes
  
  #607
              
                    vdye
  merged 3 commits into
  microsoft:vfs-2.42.0
from
vdye:vdye/sparse-checkout-crash-fix
  
      
      
   
  Sep 20, 2023 
              
            Conversation
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
    The 'dtype' arg to 'path_matches_pattern_list()' is not assumed to be initialized, and in a few callers it is not. However, the changes in 2cff5e9 (Add virtual file system settings and hook proc, 2018-01-11) _do_ assume 'dtype' is initialized. This can cause indeterminate behavior. For example, seemingly unrelated changes from 33b1b4c (sparse-checkout: avoid using internal API of unpack-trees, take 2, 2023-02-27) changed the initial value of 'dtype' in 'expand_index()' from non-zero to zero. That caused 'path_matches_pattern_list()' to call 'resolve_dtype()', which initialized the 'name_hash' and 'dir_hash' of 'istate', which triggered another bug that ultimately led to a segfault. Update the callers with uninitialized 'dtype' values to intialize with a value appropriate to their respective use cases.
In ac8acb4 (sparse-index: complete partial expansion, 2022-05-23), 'expand_index()' was updated to expand the index to a given pathspec. However, the 'path_matches_pattern_list()' method used to facilitate this has the side effect of initializing or updating the index hash variables ('name_hash', 'dir_hash', and 'name_hash_initialized'). This operation is performed on 'istate', though, not 'full'; as a result, the initialized hashes are later overwritten when copied from 'full'. To ensure the correct hashes are in 'istate' after the index expansion, change the arg used in 'path_matches_pattern_list()' from 'istate' to 'full'. Note that this does not fully solve the problem. If 'istate' does not have an initialized 'name_hash' when its contents are copied to 'full', initialized hashes will be copied back into 'istate' but 'name_hash_initialized' will be 0. Therefore, we also need to copy 'full->name_hash_initialized' back to 'istate' after the index expansion is complete. Signed-off-by: Victoria Dye <[email protected]>
Add a test verifying that sparse-checkout (with and without sparse index enabled) treat untracked files & directories correctly when changing sparse patterns. Specifically, it ensures that 'git sparse-checkout set' * deletes empty directories outside the sparse cone * does _not_ delete untracked files outside the sparse cone Signed-off-by: Victoria Dye <[email protected]>
              
                    jeffhostetler
  
              
              approved these changes
              
                  
                    Sep 20, 2023 
                  
              
              
            
            
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice!
Good find on the very obscure dtype init.
              
                    mjcheetham
  
              
              approved these changes
              
                  
                    Sep 20, 2023 
                  
              
              
            
            
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
      
        
      
      
  
    6 tasks
  
| Thank you guys so much! Awesome work and super fast response! Kudos! | 
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Nov 3, 2023 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Nov 3, 2023 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Nov 3, 2023 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Nov 3, 2023 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Nov 8, 2023 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Nov 14, 2023 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Nov 20, 2023 
    
    
  
    
  vdye 
      added a commit
      that referenced
      this pull request
    
      Feb 27, 2024 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Apr 23, 2024 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Apr 23, 2024 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Apr 23, 2024 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Apr 23, 2024 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Apr 24, 2024 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Apr 29, 2024 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      May 14, 2024 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      May 14, 2024 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      May 14, 2024 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Jun 3, 2024 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Jul 17, 2024 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Jul 18, 2024 
    
    
  
    
  mjcheetham 
      pushed a commit
      that referenced
      this pull request
    
      Jul 23, 2024 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Jul 25, 2024 
    
    
  
    
  mjcheetham 
      pushed a commit
      that referenced
      this pull request
    
      Jul 29, 2024 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Sep 18, 2024 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Sep 24, 2024 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Oct 8, 2024 
    
    
  
    
  mjcheetham 
      pushed a commit
      that referenced
      this pull request
    
      Dec 3, 2024 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Dec 17, 2024 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Jan 1, 2025 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Feb 10, 2025 
    
    
  
      
     Merged
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Feb 27, 2025 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Mar 5, 2025 
    
    
  
    
  mjcheetham 
      pushed a commit
      that referenced
      this pull request
    
      Mar 12, 2025 
    
    
  
    
  mjcheetham 
      pushed a commit
      that referenced
      this pull request
    
      Mar 17, 2025 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Jun 6, 2025 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Jun 11, 2025 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Jun 16, 2025 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Jun 16, 2025 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Jul 8, 2025 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Aug 5, 2025 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Aug 8, 2025 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Aug 13, 2025 
    
    
  
      
     Merged
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Aug 19, 2025 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Oct 17, 2025 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Oct 17, 2025 
    
    
  
    
  dscho 
      pushed a commit
      that referenced
      this pull request
    
      Oct 28, 2025 
    
    
  
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
      
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Thanks for taking the time to contribute to Git!
This fork contains changes specific to monorepo scenarios. If you are an
external contributor, then please detail your reason for submitting to
this fork:
GVFS Protocol.
This PR corrects a couple of issues in order to fix #606:
dtypearg topath_matches_pattern_list()is always initialized, since the code added in 2cff5e9 requires an initialized value.name_hash,dir_hash, andname_hash_initializedinexpand_index(). This problem originates upstream (and should eventually be fixed there as well), but it doesn't actually trigger any bugs there; it's the interaction with 2cff5e9 that causes the segfault in our fork.